<{Tinclude "commom/admin_header"}>
 <section id="container" >
      
      <!--顶部-->
      <{Tinclude"commom/admin_inner_header"}>
      <!--顶部-->
      
       <{Tinclude"commom/admin_left_menu"}>
       
       <section id="main-content">
          <section class="wrapper">
          	<h3><i class="<{if $___menuinfo["iconclass"]}><{$___menuinfo["iconclass"]}><{else}>fa fa-list-ul<{/if}>"></i><{$___menuinfo["base_name"]}></h3>
                <div class="row mt">
                    <div class="col-md-12">
                        <div class="form-panel">
                             <{if $list}>           
                            <section id="no-more-tables">                   
  <table class="table table-striped table-condensed table-hover cf">
      <thead class="cf">
        <tr>
          <th class="text-center">支付类型</th>
          <th class="text-center">图片</th>
          <th class="text-center">名称</th> 
          <th class="text-center">排序</th> 
          <th class="text-center">状态</th> 
          <th class="text-center">操作</th>
        </tr>
      </thead>
      <tbody>
              <{foreach $list as $item}>
              <tr>
                  <td data-title="支付类型" class="text-center">
                      <{$item["base_name"]}>
                  </td>
                    <td data-title="图片" class="text-center">
                        <img data-tid="<{$item["id"]}>" src="<{$item["thumb"]}>" data-psrc="<{$item["image"]}>"  class="tenanttx cursor" width="80"  />
                
                  </td>
                    <td data-title="名称" class="text-center">
                      <{$item["c_base_name"]}>
                  </td>
                  <td data-title="排序" class="text-center">
                        <{if $item["has"]==0}>
                        无
                        <{else}>
                        <input type="text" name="sort" data-rid="<{$item["relid"]}>" class="jptext" placeholder="排序" value="<{$item["rsort"]}>" /> 
                       <{/if}>
                  </td>
                   <td data-title="状态" class="text-center">
                        <{if $item["has"]==0}>
                        暂无状态
                          <{else}>
                       <div class="switch switch-mini" data-rid="<{$item["relid"]}>" data-on-label="<i class=' fa fa-check'></i>" data-off-label="<i class='fa fa-times'></i>">
                           <input type="checkbox" <{if $item["rstatus"]==1}>checked<{/if}> />
                             </div>
                           <{/if}>
                  </td>
                  <td data-title="操作" class="text-center">
                        <div class="btn-group">
                            <{if $item["has"]==0}>
                            <button class="btn btn-primary btn-xs addpay" data-pid="<{$item["id"]}>" ><span class="fa fa-plus-circle"></span>加入</button>
                            <{else}>
                            <button class="btn btn-success btn-xs payconfig" data-relid="<{$item["relid"]}>" data-toggle="modal" data-target="#paymentapiconfig" ><span class="fa fa-gear"></span>配置</button>
                           
                            <{/if}>
                            
                        </div>
                  </td>
              </tr>
              <{/foreach}>
          
      </tbody>
  </table>
                            </section>
                                <{else}>
                             <div class="col-md-12 col-xs-12">
                                 <h4 class="text-center">数据为空</h4>
                             </div>
                              <{/if}> 
                        </div>
                    </div>
                </div>
          </section>
       </section>
 </section>
<script>
    $(document).ready(function(){
        $(".addpay").click(function(){
            var pid=$(this).data("pid");
             var url="<{echo Common::RewriteUrl("PayapiManage","public_ajax_admin_rel_pay_add");}>";
            $.post(url,{"payid":pid},function(data){
                if(data.status==1){
                    window.location.reload();
                }
            },"json");
        });
        
        $(".switch").on('switch-change', function (e, data) {
            var rid=$(e.target).data("rid");
            var status=data.value?1:0;
            if(rid){
                var url="<{echo Common::RewriteUrl("PayapiManage","public_ajax_admin_rel_pay_edit_status");}>";
                $.post(url,{"rid":rid,"status":status},function(data){
                    //console.log(data);
                });
            }
        });
        function showtip(obj,msg,_timeout){
            obj.tooltip('destroy');
            obj.attr("title",msg);
            obj.tooltip({trigger:"manual"});
            obj.tooltip('show');
            window.setTimeout(function(){obj.tooltip('hide');},_timeout);
        }
        $("input[name='sort']").blur(function(){
            var rid=$(this).data("rid");
            var sort=parseInt($(this).val());
            var obj=$(this);
            if(isNaN(sort)){
                showtip(obj,"排序值请输入数字",3000);
                obj.focus();
            }
             var url="<{echo Common::RewriteUrl("PayapiManage","public_ajax_admin_rel_pay_edit_sort");}>";
                $.post(url,{"rid":rid,"sort":sort},function(data){
                    //console.log(data);
          
                    if(parseInt(data.status)==1){
                        showtip(obj,"更新排序成功",3000);
                    }
                },"json");
            
        });
    });
</script>
<{Tinclude"commom/paymentapiconfig"}>
<{Tinclude"commom/admin_footer"}>